<?php

/**
 * 友情连接相关接口
 */
class a_link extends CI_Controller {

    function __construct() {
        parent::__construct();
    }

    /**
     * 友情连接 分页
     * @param int $configid 网站id
     * @param int $typeid 友情连接类型
     * @param int $page 当前页
     * @param int $limit 显示条数
     * @return array 
     */
    function get_link_list_page($configid = 0, $typeid = 0, $page = 1, $limit = 10) {
        $where = array(
            'link.isclose' => 0
        );
        if ($configid > 0) {
            $where['link.configid'] = $configid;
        }
        if ($typeid > 0) {
            $where['link.typeid'] = $typeid;
        }
        $data = array(
            'from' => 'link',
            'column' => 'link.*',
            'where' => $where,
            'order' => 'link.listid desc',
        );
        $result = $this->m_public->get_list_page($data, $page, $limit);
        return $result;
    }

    /**
     * 友情连接列表
     * @param int $configid 网站id
     * @param int $typeid 友情连接类型
     * @param int $page 当前页
     * @param int $limit 显示条数
     * @return array 
     */
    function get_link_list($configid = 0, $typeid = 0, $limit = 10) {
        $where = array(
            'link.isclose' => 0
        );
        if ($configid > 0) {
            $where['link.configid'] = $configid;
        }
        if ($typeid > 0) {
            $where['link.typeid'] = $typeid;
        }
        $data = array(
            'from' => 'link',
            'column' => 'link.*',
            'where' => $where,
            'order' => 'link.listid desc',
            'offset'=>0,
            'limit'=>$limit,
        );
        $result = $this->m_public->get_list($data);
        return $result;
    }

}
